package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {

    /*
    * 根据分类id查询套餐
    * */
    List<Setmeal> selectByCategoryId(Long categoryId);


    /*
    * 保存套餐基本信息
    * */

    @AutoFill(value = OperationType.INSERT)
    void insert(Setmeal setmeal);

    /*
    * 分页查询
    * */
    List<Setmeal> page(String name,Integer categoryId,Integer status);

    /*
    *根据id查询套餐
    * */
    @Select("select s.id , s.price ,s.name , s.category_id , s.description , s.status , s.image , s.update_time , c.name categoryName " +
            "from setmeal s left join category c on s.category_id = c.id where s.id = #{id}")
    Setmeal selectById(Long id);

    /*
    * 根据id批量删除套餐
    * */
    void deleteByIds(List<Long> ids);
    /*
     * 修改套餐信息
     * */

    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    /*
    * 统计id在ids中的起售中的套餐数量
    * */
    Integer countSetmealOnSaleByIds(List<Long> ids);


    /*
    * 根据分类id查询套餐的数量
    * */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);



    /**
     * 根据条件统计套餐数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
